package com.shenhf.app;

import android.content.res.Resources;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.webkit.WebView;
import android.webkit.WebViewClient;
import android.widget.TextView;

import com.shenhf.about.About;
import com.shenhf.about.item.tos.TosItem;

/**
 * Created by Administrator on 2016/5/16.
 */
public class TosActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        String action = getIntent().getAction();

        switch (action) {
            case About.ACTION_URL: {
                WebView webView = new WebView(this);
                setContentView(webView);
                String url= getIntent().getStringExtra(TosItem.EXTRA_URL);
                webView.setWebViewClient(new WebViewClient() {
                    public boolean shouldOverrideUrlLoading(WebView view, String url) {
                        view.loadUrl(url);
                        return true;
                    }});
                webView.loadUrl(url);
                break;
            }
            case About.ACTION_MESSAGE_RES: {
                TextView textView = new TextView(this);
                setContentView(textView);
                int res = getIntent().getIntExtra(TosItem.EXTRA_MESSAGE_RES, 0);
                textView.setText(res);
                break;
            }
            case About.ACTION_MESSAGE: {
                TextView textView = new TextView(this);
                setContentView(textView);
                CharSequence charSequence = getIntent().getCharSequenceExtra(TosItem.EXTRA_MESSAGE);
                textView.setText(charSequence);
                break;
            }
        }

    }
}
